WinUI templates for dotnet new and VSIX#6407
Merged
Merged
Conversation
75d7c86 to
e3fc78f
Compare
…ty, and testing guidelines (#6217)
* Add pipelines * Update readme
* Adding TitleBar and .ico * Adding the ContentDialog ItemTemplate * Adding NavigationView template * Missed a csharp template and added * Push * Update WinAppSdk.CSharp.DotnetNewTemplates.csproj * Clean up navview project * Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/Pages/HomePage.xaml.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/Pages/AboutPage.xaml.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/Pages/SettingsPage.xaml.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/App.xaml.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dev/VSIX/ItemTemplates/Neutral/CSharp/ContentDialog/ContentDialog.xaml.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/MainWindow.xaml.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add default case with exception to navigation switch statement (#6252) * Initial plan * Add default case throwing InvalidOperationException in navigation switch statement Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
* Add missing item-content-dialog template for dotnet new The csproj referenced templates/item-content-dialog/ but the directory did not exist, which would cause dotnet pack to produce an incomplete package. Create the template.json, dotnetcli.host.json, and the XAML and code-behind files for a WinUI 3 ContentDialog item template. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add packaged template to NuGet template pack The templates/packaged/ directory existed with a full template.json and solution file but was never included in the csproj ItemGroups, so it would not ship in the NuGet package. Add the ItemGroup that packs the template config, solution, BlankApp, and WapProj sources. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update README with packaged and content-dialog templates The template table was missing the wasdk-packaged and wasdk-item-dialog entries. Add both so the README accurately documents all templates shipped in the pack. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add language and type tags to all template.json files Without the 'tags' property, 'dotnet new list' does not show the language column and template discoverability is reduced. Add tags.language=C# and tags.type (project, solution, or item) to every template. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add postActions for automatic NuGet restore After 'dotnet new' creates a project, the user currently has to manually run 'dotnet restore'. Add the standard NuGet restore post- action (actionId 210D431B) to the four project templates so packages are restored automatically. Item templates do not need this. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add Windows-only OS constraint to all templates WinUI 3 / Windows App SDK templates only work on Windows. Without the constraint, 'dotnet new list' shows them on Linux and macOS where they cannot build, leading to confusing errors. Add the os constraint so the templates are hidden on non-Windows hosts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add description fields to template parameters The single-project, class-library, and unit-test templates were missing description fields on their user-facing parameters. The packaged template already had them. Add matching descriptions so 'dotnet new <template> --help' displays useful parameter documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add description fields to dotnetcli.host.json files The packaged template's host file already had descriptions but the single-project, class-library, unit-test, and item-blank-window host files did not. Add descriptions so 'dotnet new <template> --help' displays useful help text for every parameter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add Copyright, license acceptance, and release notes to csproj The NuGet package was missing Copyright, PackageRequireLicenseAcceptance, and PackageReleaseNotes metadata. Add them for completeness and better presentation on NuGet feeds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update default dotnetVersion from net8.0 to net9.0 .NET 9.0 is the current release. Update the default TFM across all four project templates and their dotnetcli.host.json description examples. Users can still override with --dotnet-version net8.0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use https:// for JSON schema URLs All template.json and dotnetcli.host.json files used http:// for the schema store URLs. Update to https:// for consistency and security. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Revert packaged template from dotnet new pack The wasdk-packaged template uses a WAP project (.wapproj) which the dotnet CLI does not understand, so it cannot be used with 'dotnet new'. Remove the packaged template ItemGroup from the csproj, remove it from the README, and restore its template.json and dotnetcli.host.json to their pre-modification state. This reverts the packaged-related portions of commits 31f65f2, b8c76b7, 80c1b8f, 63d5abf, ff0bc38, 7c03a19, and 4891155. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use existing VS ContentDialog sources instead of hand-crafted copies The ContentDialog XAML and code-behind already exist at ItemTemplates/Neutral/CSharp/ContentDialog/. Link those files in the csproj instead of maintaining separate copies, matching the pattern used by the BlankWindow item template. This keeps a single source of truth and preserves the original button click handlers. Also update template.json sourceName and primaryOutputs to match the original filenames (ContentDialog, not ContentDialogItem), and remove the now-unnecessary Compile Remove directive. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Align packaged template config with other templates The previous revert restored the packaged template.json and dotnetcli.host.json to their original state, making them inconsistent with the rest of the templates. Re-apply the same improvements: add tags, constraints, postActions, update schema to https://, and default TFM to net9.0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove templates/packaged/ directory The packaged template uses a WAP project (.wapproj) which the dotnet CLI does not support, so it is not included in the NuGet template pack. Remove the unused directory to avoid confusion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update default dotnetVersion from net9.0 to net10.0 .NET 10.0 is the latest officially supported version. Update the default TFM and help text examples across all project templates. Users can still override with --dotnet-version net8.0 or net9.0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Rename template shortNames from wasdk-* to winui3-* Use winui3- prefix instead of wasdk- since WinUI 3 is the product name users recognize, not the shipping vehicle (Windows App SDK). wasdk-single -> winui3 wasdk-classlib -> winui3-lib wasdk-unittest -> winui3-unittest wasdk-item-blankwin -> winui3-window wasdk-item-dialog -> winui3-dialog Also update display names and default project names to match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add winui3-page and winui3-usercontrol item templates Add two new item templates that link existing VS template sources from ItemTemplates/Neutral/CSharp/: winui3-page - BlankPage (Page with XAML and code-behind) winui3-usercontrol - UserControl (UserControl with XAML and code-behind) Both follow the same pattern as winui3-window and winui3-dialog: the template.config is maintained locally while XAML/code-behind are linked from the shared VS template sources. Note: the dotnet new template engine does not support verifying that an existing project exists before adding an item template. The msbuild:RootNamespace binding will fall back to the default value if no project is found. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add project-capability and sdk-version constraints to item templates Item templates (window, page, usercontrol, dialog) should only appear in 'dotnet new list' when run inside a C# project folder. Add a 'project-capability' constraint with 'CSharp' so the templates are hidden when no C# project is found in the current directory. Also add an sdk-version constraint requiring .NET 8.0 or later. Inspired by https://github.com/egvijayanand/winui-templates which uses the same approach. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add sdk-version constraint to project templates Require .NET 8.0 SDK or later for the three project templates (single-project, class-library, unit-test). The templates target net10.0-windows and will not work on older SDKs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * chore(project): update NoWarn property to include CS2008 warning * feat(templates): update template identities to use WinUI naming convention * feat(templates): add symbols section to various template configurations * feat(templates): update dotnetVersion to support .NET 8, 9, and 10 choices * template renamings * User/muyuanli/naming improvements (#6256) * template renamings * Update naming and schema * Add back agents and instructions --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Muyuan Li (from Dev Box) <muyuanli@microsoft.com> Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
* Enhance copilot instructions and project spec * Fix indentation
* complete nuspec * Update dev/VSIX/DotnetNewTemplates/WinAppSdk.CSharp.DotnetNewTemplates.csproj Co-authored-by: Niels Laute <niels.laute@live.nl> * Update dev/VSIX/DotnetNewTemplates/WinAppSdk.CSharp.DotnetNewTemplates.csproj Co-authored-by: Niels Laute <niels.laute@live.nl> * Update dev/VSIX/DotnetNewTemplates/README.md Co-authored-by: Niels Laute <niels.laute@live.nl> * Resolve comments --------- Co-authored-by: Niels Laute <niels.laute@live.nl>
* Update default dotnet version to be 10.0 * Update vstemplate to be dotnet 10 as well
* set dotnet version based on installed sdk version, and increase windows sdk in tfm * Add test script and fix existing issues with item templates --------- Co-authored-by: Nikola Metulev <nmetulev@users.noreply.github.com>
* added frame and mainpage to main window * winui template updates * adding mvvm template --------- Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com>
* Remove invalid classifications and add missing XAML The classications now match the classifications from the VSIX templates * Ensures IDE shows the correct field information Also makes min version a dropdown, and sets default based on current support lifecycles / recommendations. * Add missing min versions
unify how VSIX and dotnet-new templates are declared, so adding a new C# template is a one-entry change (per Scott's review feedback). **Implementation:** - New shared manifest [`dev/Templates/templates.props`](dev/Templates/templates.props) with 6 item types covering the dotnet-new × VSIX matrix (shared / VSIX-only / dotnet-new-only, × project / item). - Dotnet csproj: inline C# MSBuild task expands the manifest into `<None Pack=true>` items. - VSIX csproj: MSBuild item transforms turn the manifest into `<ProjectReference>` items. **Verified:** `dotnet pack` output is byte-equal to pre-refactor (179 files); VSIX evaluation still resolves all 14 template ProjectReferences; C++ VSIX is untouched. **Docs:** [`how-to-create-a-new-csharp-template.md`](dev/Templates/how-to-create-a-new-csharp-template.md).
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Scottj1s
reviewed
May 13, 2026
Scottj1s
reviewed
May 13, 2026
…ect' qualifier from descriptions
…t '.Legacy' suffix from UserControl identity
Contributor
Author
|
To reviewers, I found there were 2 orphan item templates in Dotnet files:
which were duplicates of the items actually included in the package:
The orphans were never referenced by templates.props and never made it into the generated
|
…om blank-app template (they will be re-organised in a follow-up PR)
ecca4da to
5881332
Compare
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Scottj1s
approved these changes
May 15, 2026
niels9001
approved these changes
May 16, 2026
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds/updates the WinUI App templates:
dotnet new